import { Body, Get, Inject, Post, Provide, Query } from '@midwayjs/decorator';
import {
  CoolController,
  BaseController,
} from '@cool-midway/core';
import { BusinessGalleryEntity } from '../../entity/gallery';
import { BusinessGalleryService } from '../../service/gallery';

/**
 * 图库
 */
@Provide()
@CoolController({
  api: [],
  entity: BusinessGalleryEntity,
  service: BusinessGalleryService,
})
export class BusinessAppGalleryController extends BaseController {
  @Inject()
  businessGalleryService: BusinessGalleryService;
  /**
   * 新增
   */
  @Post('/addItem', { summary: '新增' })
  async addItem(@Body() body) {
    return this.ok(await this.businessGalleryService.addItem(body));
  }

  /**
 * 更新
 */
  @Post('/update', { summary: '更新' })
  async updateByUser(@Body() body) {
    return this.ok(await this.businessGalleryService.updateByUser(body));
  }

  /**
   * 获取分页数据
   */
  @Post('/page', { summary: '获取分页数据' })
  async getPageByUser(@Body() body) {
    const result = await this.businessGalleryService.getPageByUser(body);
    return this.ok(result);
  }
  /**
   * 获取详细信息
   */
  @Get('/info', { summary: '获取详细信息' })
  async getInfoByUser(@Query('id') id: number) {
    const result = await this.businessGalleryService.getInfoByUser(id);
    return this.ok(result);
  }
}
